package sap.gui;


import data.*;
import exceptions.*;
import sap.provider.*;

import javax.swing.*;




/*
 * ClassRoomFinder.java
 *
 * Created on 10 de noviembre de 2007, 11:41 AM
 */

/**
 *
 * @author  Enrique Garcia
 */
public final class ProjectManager extends javax.swing.JPanel{
    
    /** Creates new form ClassRoomFinder */
    public ProjectManager(CManager cm) {
        initComponents();
        init();
        initC();
        instance = this;
        this.cm=cm;
    }

    public void init()
    {
    jPanel1.setVisible(false);
    run.setVisible(false);
    jTextField1.setEditable(false);
    jTextField22.setVisible(true);
    jTextField41.setVisible(false);
    jTextField41.setEditable(false);

    }

    public void init(String project_def)
    {
        this.project_def = project_def;
        jTextField1.setText(project_def);
        jPanel1.setVisible(false);
        run.setVisible(false);
        jTextField1.setEditable(false);
        jTextField22.setVisible(true);
        jTextField41.setVisible(false);
        jTextField41.setEditable(false);
        this.Tipos.setSelectedIndex(0);

    }

    public void initC()
    {
        profiles = Profiles.get();
				for (int i=0; i<profiles.length; i++)
					jTextField22.insertItemAt(profiles[i].name, i);
    }

    public void clear()
    {
        jTextField2.setText("");
        jTextField3.setText("");
		jTextField4.setText("");
        jTextField5.setText("");
        jTextField6.setText("");
		jTextField7.setText("");
        jTextField8.setText("");
        jTextField9.setText("");
		jTextField10.setText("");
        jTextField11.setText("");
        jTextField12.setText("");
        jTextField13.setText("");
        jTextField14.setText("");
        jTextField15.setText("");
		jTextField16.setText("");
        jTextField17.setText("");
        jTextField18.setText("");
		jTextField19.setText("");
        jTextField20.setText("");
        jTextField21.setText("");
		jTextField22.setSelectedIndex(0);
		jTextField23.setText("");
        jTextField24.setText("");
		jTextField25.setText("");
        jTextField26.setText("");
        jTextField27.setText("");
        jTextField28.setText("");
        jTextField29.setText("");
        jTextField30.setText("");
		jTextField31.setText("");
        jTextField32.setText("");
        jTextField33.setText("");
        jTextField34.setText("");
        jTextField35.setText("");
        jTextField36.setText("");
        jTextField37.setText("");
        jTextField38.setText("");
        jTextField39.setText("");
        jTextField40.setText("");
    }

    private void setDialogFromStructure(ProjectDefinition project) {
        jTextField2.setText(project.description);
        jTextField3.setText(project.mask_id);
		jTextField4.setText(project.responsible_no);
        jTextField5.setText(project.applicant_no);
        jTextField6.setText(project.comp_code);
		jTextField7.setText(project.bus_area);
        jTextField8.setText(project.controlling_area);
        jTextField9.setText(project.profit_ctr);
		jTextField10.setText(project.project_currency);
        jTextField11.setText(project.project_currency_iso);
        jTextField12.setText(project.network_assignment);
        jTextField13.setText(project.start);
        jTextField14.setText(project.finish);
        jTextField15.setText(project.plant);
		jTextField16.setText(project.calendar);
        jTextField17.setText(project.plan_basic);
        jTextField18.setText(project.plan_fcst);
		jTextField19.setText(project.time_unit);
        jTextField20.setText(project.time_unit_iso);
        jTextField21.setText(project.network_profile);
		jTextField41.setText(project.project_profile);
        jTextField41.setVisible(true);
        jTextField22.setVisible(false);
		jTextField23.setText(project.budget_profile);
        jTextField24.setText(project.project_stock );
		jTextField25.setText(project.objectclass );
        jTextField26.setText(project.statistical );
        jTextField27.setText(project.taxjurcode );
        jTextField28.setText(project.int_profile);
        jTextField29.setText(project.wbs_sched_profile );
        jTextField30.setText(project.csh_bdgt_profile );
        jTextField31.setText(project.plan_profile );
        jTextField32.setText(project.joint_venture );
        jTextField33.setText(project.recovery_ind );
        jTextField34.setText(project.equity_type );
        jTextField35.setText(project.jv_object_type );
        jTextField36.setText(project.jv_jib_class );
        jTextField37.setText(project.jv_jib_sub_class );
        jTextField38.setText(project.objectclass_ext );
        jTextField39.setText(project.func_area );
        jTextField40.setText(project.func_area_long );
	}
    

    private ProjectDefinition getListFromDialog() {
        
        ProjectDefinition project = new ProjectDefinition();
        project.project_definition = jTextField1.getText();
        project.description = jTextField2.getText();
		project.mask_id = jTextField3.getText();
        project.responsible_no = jTextField4.getText();
        project.applicant_no = jTextField5.getText();
        project.comp_code = jTextField6.getText();
        project.bus_area = jTextField7.getText();
        project.controlling_area = jTextField8.getText();
        project.profit_ctr = jTextField9.getText();
        project.project_currency = jTextField10.getText();
        project.project_currency_iso = jTextField11.getText();
        project.network_assignment = jTextField12.getText();
        project.start = jTextField13.getText();
        project.finish = jTextField14.getText();
        project.plant = jTextField15.getText();
        project.calendar = jTextField16.getText();
        project.plan_basic = jTextField17.getText();
        project.plan_fcst = jTextField18.getText();
        project.time_unit = jTextField19.getText();
        project.time_unit_iso = jTextField20.getText();
        project.network_profile = jTextField21.getText();
        project.project_profile = profiles[jTextField22.getSelectedIndex()].id;
        project.budget_profile = jTextField23.getText();
        project.project_stock = jTextField24.getText();
        project.objectclass = jTextField25.getText();
        project.statistical = jTextField26.getText();
        project.taxjurcode = jTextField27.getText();
        project.int_profile = jTextField28.getText();
        project.wbs_sched_profile = jTextField29.getText();
        project.csh_bdgt_profile = jTextField30.getText();
        project.plan_profile = jTextField31.getText();
        project.joint_venture = jTextField32.getText();
        project.recovery_ind = jTextField33.getText();
        project.equity_type = jTextField34.getText();
        project.jv_object_type = jTextField35.getText();
        project.jv_jib_class = jTextField36.getText();
        project.jv_jib_sub_class = jTextField37.getText();
        project.objectclass_ext = jTextField38.getText();
        project.func_area = jTextField39.getText();
        project.func_area_long = jTextField40.getText();

                return project;
                
    }



    
  
    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        run = new javax.swing.JButton();
        Tipos = new javax.swing.JComboBox();
        jPanel1 = new javax.swing.JPanel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();
        jLabel12 = new javax.swing.JLabel();
        jLabel13 = new javax.swing.JLabel();
        jLabel14 = new javax.swing.JLabel();
        jLabel15 = new javax.swing.JLabel();
        jLabel16 = new javax.swing.JLabel();
        jTextField2 = new javax.swing.JTextField();
        jTextField3 = new javax.swing.JTextField();
        jTextField4 = new javax.swing.JTextField();
        jTextField5 = new javax.swing.JTextField();
        jTextField6 = new javax.swing.JTextField();
        jTextField7 = new javax.swing.JTextField();
        jTextField8 = new javax.swing.JTextField();
        jTextField9 = new javax.swing.JTextField();
        jTextField10 = new javax.swing.JTextField();
        jTextField11 = new javax.swing.JTextField();
        jTextField12 = new javax.swing.JTextField();
        jTextField13 = new javax.swing.JTextField();
        jTextField14 = new javax.swing.JTextField();
        jLabel17 = new javax.swing.JLabel();
        jLabel18 = new javax.swing.JLabel();
        jLabel19 = new javax.swing.JLabel();
        jLabel20 = new javax.swing.JLabel();
        jLabel21 = new javax.swing.JLabel();
        jLabel22 = new javax.swing.JLabel();
        jLabel23 = new javax.swing.JLabel();
        jLabel24 = new javax.swing.JLabel();
        jLabel25 = new javax.swing.JLabel();
        jLabel26 = new javax.swing.JLabel();
        jLabel27 = new javax.swing.JLabel();
        jLabel28 = new javax.swing.JLabel();
        jLabel29 = new javax.swing.JLabel();
        jTextField15 = new javax.swing.JTextField();
        jTextField16 = new javax.swing.JTextField();
        jTextField17 = new javax.swing.JTextField();
        jTextField18 = new javax.swing.JTextField();
        jTextField19 = new javax.swing.JTextField();
        jTextField20 = new javax.swing.JTextField();
        jTextField21 = new javax.swing.JTextField();
        jTextField22 = new javax.swing.JComboBox();
        jTextField23 = new javax.swing.JTextField();
        jTextField24 = new javax.swing.JTextField();
        jTextField25 = new javax.swing.JTextField();
        jTextField26 = new javax.swing.JTextField();
        jTextField27 = new javax.swing.JTextField();
        jLabel30 = new javax.swing.JLabel();
        jLabel31 = new javax.swing.JLabel();
        jLabel32 = new javax.swing.JLabel();
        jLabel33 = new javax.swing.JLabel();
        jLabel34 = new javax.swing.JLabel();
        jLabel35 = new javax.swing.JLabel();
        jLabel36 = new javax.swing.JLabel();
        jLabel37 = new javax.swing.JLabel();
        jLabel38 = new javax.swing.JLabel();
        jLabel39 = new javax.swing.JLabel();
        jLabel40 = new javax.swing.JLabel();
        jLabel41 = new javax.swing.JLabel();
        jLabel42 = new javax.swing.JLabel();
        jTextField28 = new javax.swing.JTextField();
        jTextField29 = new javax.swing.JTextField();
        jTextField30 = new javax.swing.JTextField();
        jTextField31 = new javax.swing.JTextField();
        jTextField32 = new javax.swing.JTextField();
        jTextField33 = new javax.swing.JTextField();
        jTextField34 = new javax.swing.JTextField();
        jTextField35 = new javax.swing.JTextField();
        jTextField36 = new javax.swing.JTextField();
        jTextField37 = new javax.swing.JTextField();
        jTextField38 = new javax.swing.JTextField();
        jTextField39 = new javax.swing.JTextField();
        jTextField40 = new javax.swing.JTextField();
        ok = new javax.swing.JButton();
        cancel = new javax.swing.JButton();
        jTextField41 = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        jTextField1 = new javax.swing.JTextField();

        setBackground(new java.awt.Color(0, 0, 0));
        setLayout(null);

        jLabel1.setForeground(new java.awt.Color(255, 255, 255));
        jLabel1.setText("Choose one function");
        add(jLabel1);
        jLabel1.setBounds(10, 10, 100, 20);

        run.setBackground(new java.awt.Color(0, 0, 0));
        run.setText("Run");
        run.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                runActionPerformed(evt);
            }
        });
        add(run);
        run.setBounds(420, 20, 130, 30);

        Tipos.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Choose one function", "Create Project", "Edit Project", "Delete Project" }));
        Tipos.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                TiposItemStateChanged(evt);
            }
        });
        add(Tipos);
        Tipos.setBounds(10, 30, 180, 20);

        jPanel1.setBackground(new java.awt.Color(0, 0, 0));
        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Project Details", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 11), new java.awt.Color(255, 255, 255))); // NOI18N
        jPanel1.setForeground(new java.awt.Color(255, 255, 255));
        jPanel1.setLayout(null);

        jLabel4.setForeground(new java.awt.Color(255, 255, 255));
        jLabel4.setText("DESCRIPTION");
        jPanel1.add(jLabel4);
        jLabel4.setBounds(20, 40, 140, 14);

        jLabel5.setForeground(new java.awt.Color(255, 255, 255));
        jLabel5.setText("MASK_ID");
        jPanel1.add(jLabel5);
        jLabel5.setBounds(20, 70, 140, 14);

        jLabel6.setForeground(new java.awt.Color(255, 255, 255));
        jLabel6.setText("RESPONSIBLE_NO");
        jPanel1.add(jLabel6);
        jLabel6.setBounds(20, 100, 140, 14);

        jLabel7.setForeground(new java.awt.Color(255, 255, 255));
        jLabel7.setText("APPLICANT_NO");
        jPanel1.add(jLabel7);
        jLabel7.setBounds(20, 130, 140, 14);

        jLabel8.setForeground(new java.awt.Color(255, 255, 255));
        jLabel8.setText("COMP_CODE");
        jPanel1.add(jLabel8);
        jLabel8.setBounds(20, 160, 140, 14);

        jLabel9.setForeground(new java.awt.Color(255, 255, 255));
        jLabel9.setText("BUS_AREA");
        jPanel1.add(jLabel9);
        jLabel9.setBounds(20, 190, 140, 14);

        jLabel10.setForeground(new java.awt.Color(255, 255, 255));
        jLabel10.setText("CONTROLLING_AREA");
        jPanel1.add(jLabel10);
        jLabel10.setBounds(20, 220, 140, 14);

        jLabel11.setForeground(new java.awt.Color(255, 255, 255));
        jLabel11.setText("PROFIT_CTR");
        jPanel1.add(jLabel11);
        jLabel11.setBounds(20, 250, 140, 14);

        jLabel12.setForeground(new java.awt.Color(255, 255, 255));
        jLabel12.setText("PROJECT_CURRENCY");
        jPanel1.add(jLabel12);
        jLabel12.setBounds(20, 280, 140, 14);

        jLabel13.setForeground(new java.awt.Color(255, 255, 255));
        jLabel13.setText("PROJECT_CURRENCY_ISO");
        jPanel1.add(jLabel13);
        jLabel13.setBounds(20, 310, 140, 14);

        jLabel14.setForeground(new java.awt.Color(255, 255, 255));
        jLabel14.setText("NETWORK_ASSIGNMENT");
        jPanel1.add(jLabel14);
        jLabel14.setBounds(20, 340, 140, 14);

        jLabel15.setForeground(new java.awt.Color(255, 255, 255));
        jLabel15.setText("START");
        jPanel1.add(jLabel15);
        jLabel15.setBounds(20, 370, 140, 14);

        jLabel16.setForeground(new java.awt.Color(255, 255, 255));
        jLabel16.setText("FINISH");
        jPanel1.add(jLabel16);
        jLabel16.setBounds(20, 400, 140, 14);
        jPanel1.add(jTextField2);
        jTextField2.setBounds(150, 40, 100, 20);
        jPanel1.add(jTextField3);
        jTextField3.setBounds(150, 70, 100, 20);
        jPanel1.add(jTextField4);
        jTextField4.setBounds(150, 100, 100, 20);
        jPanel1.add(jTextField5);
        jTextField5.setBounds(150, 130, 100, 20);
        jPanel1.add(jTextField6);
        jTextField6.setBounds(150, 160, 100, 20);
        jPanel1.add(jTextField7);
        jTextField7.setBounds(150, 190, 100, 20);
        jPanel1.add(jTextField8);
        jTextField8.setBounds(150, 220, 100, 20);
        jPanel1.add(jTextField9);
        jTextField9.setBounds(150, 250, 100, 20);
        jPanel1.add(jTextField10);
        jTextField10.setBounds(150, 280, 100, 20);
        jPanel1.add(jTextField11);
        jTextField11.setBounds(150, 310, 100, 20);
        jPanel1.add(jTextField12);
        jTextField12.setBounds(150, 340, 100, 20);
        jPanel1.add(jTextField13);
        jTextField13.setBounds(150, 370, 100, 20);
        jPanel1.add(jTextField14);
        jTextField14.setBounds(150, 400, 100, 20);

        jLabel17.setForeground(new java.awt.Color(255, 255, 255));
        jLabel17.setText("PLANT");
        jPanel1.add(jLabel17);
        jLabel17.setBounds(300, 40, 100, 14);

        jLabel18.setForeground(new java.awt.Color(255, 255, 255));
        jLabel18.setText("CALENDAR");
        jPanel1.add(jLabel18);
        jLabel18.setBounds(300, 70, 100, 14);

        jLabel19.setForeground(new java.awt.Color(255, 255, 255));
        jLabel19.setText("PLAN_BASIC");
        jPanel1.add(jLabel19);
        jLabel19.setBounds(300, 100, 100, 14);

        jLabel20.setForeground(new java.awt.Color(255, 255, 255));
        jLabel20.setText("PLAN_FCST");
        jPanel1.add(jLabel20);
        jLabel20.setBounds(300, 130, 100, 14);

        jLabel21.setForeground(new java.awt.Color(255, 255, 255));
        jLabel21.setText("TIME_UNIT");
        jPanel1.add(jLabel21);
        jLabel21.setBounds(300, 160, 100, 14);

        jLabel22.setForeground(new java.awt.Color(255, 255, 255));
        jLabel22.setText("TIME_UNIT_ISO");
        jPanel1.add(jLabel22);
        jLabel22.setBounds(300, 190, 100, 14);

        jLabel23.setForeground(new java.awt.Color(255, 255, 255));
        jLabel23.setText("NETWORK_PROFILE");
        jPanel1.add(jLabel23);
        jLabel23.setBounds(300, 220, 100, 14);

        jLabel24.setForeground(new java.awt.Color(255, 255, 255));
        jLabel24.setText("PROJECT_PROFILE*");
        jPanel1.add(jLabel24);
        jLabel24.setBounds(300, 250, 100, 14);

        jLabel25.setForeground(new java.awt.Color(255, 255, 255));
        jLabel25.setText("BUDGET_PROFILE");
        jPanel1.add(jLabel25);
        jLabel25.setBounds(300, 280, 100, 14);

        jLabel26.setForeground(new java.awt.Color(255, 255, 255));
        jLabel26.setText("PROJECT_STOCK");
        jPanel1.add(jLabel26);
        jLabel26.setBounds(300, 310, 100, 14);

        jLabel27.setForeground(new java.awt.Color(255, 255, 255));
        jLabel27.setText("OBJECTCLASS");
        jPanel1.add(jLabel27);
        jLabel27.setBounds(300, 340, 100, 14);

        jLabel28.setForeground(new java.awt.Color(255, 255, 255));
        jLabel28.setText("STATISTICAL");
        jPanel1.add(jLabel28);
        jLabel28.setBounds(300, 370, 100, 14);

        jLabel29.setForeground(new java.awt.Color(255, 255, 255));
        jLabel29.setText("TAXJURCODE");
        jPanel1.add(jLabel29);
        jLabel29.setBounds(300, 400, 100, 14);
        jPanel1.add(jTextField15);
        jTextField15.setBounds(410, 40, 100, 20);
        jPanel1.add(jTextField16);
        jTextField16.setBounds(410, 70, 100, 20);
        jPanel1.add(jTextField17);
        jTextField17.setBounds(410, 100, 100, 20);
        jPanel1.add(jTextField18);
        jTextField18.setBounds(410, 130, 100, 20);
        jPanel1.add(jTextField19);
        jTextField19.setBounds(410, 160, 100, 20);
        jPanel1.add(jTextField20);
        jTextField20.setBounds(410, 190, 100, 20);
        jPanel1.add(jTextField21);
        jTextField21.setBounds(410, 220, 100, 20);

        jPanel1.add(jTextField22);
        jTextField22.setBounds(410, 250, 100, 20);
        jPanel1.add(jTextField23);
        jTextField23.setBounds(410, 280, 100, 20);
        jPanel1.add(jTextField24);
        jTextField24.setBounds(410, 310, 100, 20);
        jPanel1.add(jTextField25);
        jTextField25.setBounds(410, 340, 100, 20);
        jPanel1.add(jTextField26);
        jTextField26.setBounds(410, 370, 100, 20);
        jPanel1.add(jTextField27);
        jTextField27.setBounds(410, 400, 100, 20);

        jLabel30.setForeground(new java.awt.Color(255, 255, 255));
        jLabel30.setText("INT_PROFILE");
        jPanel1.add(jLabel30);
        jLabel30.setBounds(550, 40, 110, 14);

        jLabel31.setForeground(new java.awt.Color(255, 255, 255));
        jLabel31.setText("PSP_SCHED_PROFILE");
        jPanel1.add(jLabel31);
        jLabel31.setBounds(550, 70, 110, 14);

        jLabel32.setForeground(new java.awt.Color(255, 255, 255));
        jLabel32.setText("CSH_BDGT_PROFILE");
        jPanel1.add(jLabel32);
        jLabel32.setBounds(550, 100, 110, 14);

        jLabel33.setForeground(new java.awt.Color(255, 255, 255));
        jLabel33.setText("PLAN_PROFILE");
        jPanel1.add(jLabel33);
        jLabel33.setBounds(550, 130, 110, 14);

        jLabel34.setForeground(new java.awt.Color(255, 255, 255));
        jLabel34.setText("JOINT_VENTURE");
        jPanel1.add(jLabel34);
        jLabel34.setBounds(550, 160, 110, 14);

        jLabel35.setForeground(new java.awt.Color(255, 255, 255));
        jLabel35.setText("RECOVERY_IND");
        jPanel1.add(jLabel35);
        jLabel35.setBounds(550, 190, 110, 14);

        jLabel36.setForeground(new java.awt.Color(255, 255, 255));
        jLabel36.setText("EQUITY_TYPE");
        jPanel1.add(jLabel36);
        jLabel36.setBounds(550, 220, 110, 14);

        jLabel37.setForeground(new java.awt.Color(255, 255, 255));
        jLabel37.setText("JV_OBJECT_TYPE");
        jPanel1.add(jLabel37);
        jLabel37.setBounds(550, 250, 110, 14);

        jLabel38.setForeground(new java.awt.Color(255, 255, 255));
        jLabel38.setText("JV_JIB_CLASS");
        jPanel1.add(jLabel38);
        jLabel38.setBounds(550, 280, 110, 14);

        jLabel39.setForeground(new java.awt.Color(255, 255, 255));
        jLabel39.setText("JV_JIB_SUB_CLASS_A");
        jPanel1.add(jLabel39);
        jLabel39.setBounds(550, 310, 110, 14);

        jLabel40.setForeground(new java.awt.Color(255, 255, 255));
        jLabel40.setText("OBJECTCLASS_EXT");
        jPanel1.add(jLabel40);
        jLabel40.setBounds(550, 340, 110, 14);

        jLabel41.setForeground(new java.awt.Color(255, 255, 255));
        jLabel41.setText("FUNC_AREA");
        jPanel1.add(jLabel41);
        jLabel41.setBounds(550, 370, 110, 14);

        jLabel42.setForeground(new java.awt.Color(255, 255, 255));
        jLabel42.setText("FUNC_AREA_LONG");
        jPanel1.add(jLabel42);
        jLabel42.setBounds(550, 400, 110, 14);
        jPanel1.add(jTextField28);
        jTextField28.setBounds(660, 40, 100, 20);
        jPanel1.add(jTextField29);
        jTextField29.setBounds(660, 70, 100, 20);
        jPanel1.add(jTextField30);
        jTextField30.setBounds(660, 100, 100, 20);
        jPanel1.add(jTextField31);
        jTextField31.setBounds(660, 130, 100, 20);
        jPanel1.add(jTextField32);
        jTextField32.setBounds(660, 160, 100, 20);
        jPanel1.add(jTextField33);
        jTextField33.setBounds(660, 190, 100, 20);
        jPanel1.add(jTextField34);
        jTextField34.setBounds(660, 220, 100, 20);
        jPanel1.add(jTextField35);
        jTextField35.setBounds(660, 250, 100, 20);
        jPanel1.add(jTextField36);
        jTextField36.setBounds(660, 280, 100, 20);
        jPanel1.add(jTextField37);
        jTextField37.setBounds(660, 310, 100, 20);
        jPanel1.add(jTextField38);
        jTextField38.setBounds(660, 340, 100, 20);
        jPanel1.add(jTextField39);
        jTextField39.setBounds(660, 370, 100, 20);
        jPanel1.add(jTextField40);
        jTextField40.setBounds(660, 400, 100, 20);

        ok.setText("Ok");
        ok.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                okActionPerformed(evt);
            }
        });
        jPanel1.add(ok);
        ok.setBounds(260, 440, 100, 23);

        cancel.setText("Cancel");
        cancel.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cancelActionPerformed(evt);
            }
        });
        jPanel1.add(cancel);
        cancel.setBounds(410, 440, 100, 23);
        jPanel1.add(jTextField41);
        jTextField41.setBounds(410, 250, 100, 20);

        add(jPanel1);
        jPanel1.setBounds(10, 60, 810, 490);

        jLabel3.setForeground(new java.awt.Color(255, 255, 255));
        jLabel3.setText("PROJECT_DEFINITION");
        add(jLabel3);
        jLabel3.setBounds(230, 10, 140, 14);
        add(jTextField1);
        jTextField1.setBounds(230, 30, 140, 20);
    }// </editor-fold>//GEN-END:initComponents

    private void TiposItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_TiposItemStateChanged
        
        JComboBox cb = (JComboBox)evt.getSource();
        
        src = cb.getSelectedIndex();
        
        switch(src)
        {
                case 0:
                   
                    break;
                case 1:
                    this.clear();
                    this.init();
                    jPanel1.setVisible(true);
                    break;
                case 2:
                    this.clear();
                    this.init();
                    run.setVisible(true);
                    break;
                case 3:
                    this.clear();
                    this.init();
                    run.setVisible(true);
                    break;

        }


    }//GEN-LAST:event_TiposItemStateChanged

    private void okActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okActionPerformed
        // TODO add your handling code here:
        if(src==1)
        {
            try {
                    sap.provider.Project.create(getListFromDialog());
                } catch (ReturnException ex) {
                    JOptionPane.showMessageDialog(cm, ex.getMessage(), "Exception", JOptionPane.ERROR_MESSAGE);
                }
        this.clear();
        this.init();
        }
         else
            if(src==2)
            {
                try {
                    sap.provider.Project.maintain(getListFromDialog());
                } catch (ReturnException ex) {
                    JOptionPane.showMessageDialog(cm, ex.getMessage(), "Exception", JOptionPane.ERROR_MESSAGE);
                }
                this.clear();
                this.init();
            }

            Tipos.setSelectedIndex(0);
    }//GEN-LAST:event_okActionPerformed

    private void cancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelActionPerformed

        this.clear();
        this.init();
        Tipos.setSelectedIndex(0);
    }//GEN-LAST:event_cancelActionPerformed

    private void runActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_runActionPerformed

        
        if(src==0)
        {
             JOptionPane.showMessageDialog(cm, "You need to select one " +
                            "option", "Error", JOptionPane.ERROR_MESSAGE);
             this.clear();
             this.init();
             
        }
            else
            if(src==2)
            {
                
            try
                    {
                        if (Project.exists(jTextField1.getText()))
                        {
                            ProjectDefinition project = Project.get(jTextField1.getText());
                            this.setDialogFromStructure(project);
                            jPanel1.setVisible(true);
                            run.setVisible(false);
                            jTextField1.setEditable(false);
                            cm.Tree.setVisible(true);
                            cm.treeModel(Project.getHierarchy(jTextField1.getText()), jTextField1.getText());
                            cm.gant.init(jTextField1.getText());
                        }
                        else
                            {
                             JOptionPane.showMessageDialog(cm, "Project does not exist",
                                    "Error", JOptionPane.ERROR_MESSAGE);
                            }
                     } catch (ReturnException ex)
                            {
                            JOptionPane.showMessageDialog(cm, ex.getMessage(), "Exception", JOptionPane.ERROR_MESSAGE);
                            }
                
            }
            if(src==3)
            {
                try {
					Project.delete(jTextField1.getText());
					JOptionPane.showMessageDialog(cm, "Project Removed", "Info", JOptionPane.INFORMATION_MESSAGE);
			} catch (ReturnException ex) {
				JOptionPane.showMessageDialog(cm, ex.getMessage(), "Exception", JOptionPane.ERROR_MESSAGE);
			}
                
            }


    }//GEN-LAST:event_runActionPerformed


 
    

    public static ProjectManager getInstance() {
		return instance;
	}
    
    private javax.swing.ButtonGroup criteriaGroup;
    private CManager cm;
    protected static final String COWNER="COWNER";    
    private String Tabla = "PRO";
    private String Criterio;
    private static ProjectManager instance = null;
    private int src;
    private data.ProjectProfile[] profiles;
    private String project_def;
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JComboBox Tipos;
    private javax.swing.JButton cancel;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel18;
    private javax.swing.JLabel jLabel19;
    private javax.swing.JLabel jLabel20;
    private javax.swing.JLabel jLabel21;
    private javax.swing.JLabel jLabel22;
    private javax.swing.JLabel jLabel23;
    private javax.swing.JLabel jLabel24;
    private javax.swing.JLabel jLabel25;
    private javax.swing.JLabel jLabel26;
    private javax.swing.JLabel jLabel27;
    private javax.swing.JLabel jLabel28;
    private javax.swing.JLabel jLabel29;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel30;
    private javax.swing.JLabel jLabel31;
    private javax.swing.JLabel jLabel32;
    private javax.swing.JLabel jLabel33;
    private javax.swing.JLabel jLabel34;
    private javax.swing.JLabel jLabel35;
    private javax.swing.JLabel jLabel36;
    private javax.swing.JLabel jLabel37;
    private javax.swing.JLabel jLabel38;
    private javax.swing.JLabel jLabel39;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel40;
    private javax.swing.JLabel jLabel41;
    private javax.swing.JLabel jLabel42;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    public static javax.swing.JTextField jTextField1;
    private javax.swing.JTextField jTextField10;
    private javax.swing.JTextField jTextField11;
    private javax.swing.JTextField jTextField12;
    private javax.swing.JTextField jTextField13;
    private javax.swing.JTextField jTextField14;
    private javax.swing.JTextField jTextField15;
    private javax.swing.JTextField jTextField16;
    private javax.swing.JTextField jTextField17;
    private javax.swing.JTextField jTextField18;
    private javax.swing.JTextField jTextField19;
    private javax.swing.JTextField jTextField2;
    private javax.swing.JTextField jTextField20;
    private javax.swing.JTextField jTextField21;
    private javax.swing.JComboBox jTextField22;
    private javax.swing.JTextField jTextField23;
    private javax.swing.JTextField jTextField24;
    private javax.swing.JTextField jTextField25;
    private javax.swing.JTextField jTextField26;
    private javax.swing.JTextField jTextField27;
    private javax.swing.JTextField jTextField28;
    private javax.swing.JTextField jTextField29;
    private javax.swing.JTextField jTextField3;
    private javax.swing.JTextField jTextField30;
    private javax.swing.JTextField jTextField31;
    private javax.swing.JTextField jTextField32;
    private javax.swing.JTextField jTextField33;
    private javax.swing.JTextField jTextField34;
    private javax.swing.JTextField jTextField35;
    private javax.swing.JTextField jTextField36;
    private javax.swing.JTextField jTextField37;
    private javax.swing.JTextField jTextField38;
    private javax.swing.JTextField jTextField39;
    private javax.swing.JTextField jTextField4;
    private javax.swing.JTextField jTextField40;
    private javax.swing.JTextField jTextField41;
    private javax.swing.JTextField jTextField5;
    private javax.swing.JTextField jTextField6;
    private javax.swing.JTextField jTextField7;
    private javax.swing.JTextField jTextField8;
    private javax.swing.JTextField jTextField9;
    private javax.swing.JButton ok;
    private javax.swing.JButton run;
    // End of variables declaration//GEN-END:variables
    
}
